package cn.edu.scau.cmi.zhengweibo.composite.safe;

import java.util.ArrayList;
import java.util.List;

public abstract class SafeComponent {

	public String name;
	
	public List<SafeComponent> child = new ArrayList<>();

	public SafeComponent(String name) {
		this.name = name;
	}

	public abstract String getName();
	
	public abstract void show(String str);
	
	public abstract String show1(String str);
	
	public  SafeComponent find(String name) {
		for(SafeComponent s : child) {
			if(s.getName().equals(name)){
				return s;
			}else if(s.child!=null) {
				for(SafeComponent c : s.child) {
					c.find(name);
				}
			}
		}
		return null;
	}
  
}
